import javax.swing.JOptionPane;

public class MaxLengthOfNames {

	public static void main(String[] args) {

		Integer maxlength = Integer.MIN_VALUE;
		Integer minlength = Integer.MAX_VALUE;
		String maxname = "";
		String minname = "";

		for (Integer i = 0; i < 4; i++) {

			String username = JOptionPane
					.showInputDialog("Enter name and surname [" + i
							+ "] i.e. Rafal Fusik");

			if (username.length() > maxlength) {
				maxlength = username.length();
				maxname = username;

			}

			if (username.length() < minlength) {
				minlength = username.length();
				minname = username;
			}
		}

		JOptionPane.showMessageDialog(null, "Max lenght: " + maxlength
				+ ". Name: " + maxname + "\nMin lenght : " + minlength
				+ ". Name: " + minname);

	}
}
